package com.demo.controller;

import com.demo.common.Result;
import com.demo.service.IntelligentScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * Bean测试控制器
 */
@RestController
@RequestMapping("/bean-test")
@CrossOrigin
public class BeanTestController {
    
    @Autowired
    private IntelligentScheduleService intelligentScheduleService;
    
    @Autowired
    @Qualifier("simpleScheduleService")
    private IntelligentScheduleService simpleScheduleService;
    
    /**
     * 测试Bean注入
     */
    @GetMapping("/test-beans")
    public Result<Map<String, Object>> testBeans() {
        try {
            Map<String, Object> result = new HashMap<>();
            
            result.put("intelligentScheduleService", intelligentScheduleService.getClass().getSimpleName());
            result.put("simpleScheduleService", simpleScheduleService.getClass().getSimpleName());
            result.put("areDifferent", !intelligentScheduleService.getClass().equals(simpleScheduleService.getClass()));
            
            return Result.success(result);
        } catch (Exception e) {
            return Result.error("Bean测试失败：" + e.getMessage());
        }
    }
}
























